package rj.servlet.chapter03;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;

@WebServlet(name="Showlnfomation",urlPatterns = "/Showlnfomation")
public class Showlnfomation extends GenericServlet {

    @Override
    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        // 设置响应内容类型
        res.setContentType("text/html;charset=UTF-8");

        // 获取 PrintWriter 对象，用于向客户端发送数据
        PrintWriter out = res.getWriter();

        // 输出 HTML 内容
        out.println("<html><head>");
        out.println("<title>个人信息</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>个人信息</h1>");
        out.println("<p>专业: 计算机科学与技术</p>");
        out.println("<p>班级: 2019级计算机科学与技术1班</p>");
        out.println("<p>学号: 2019123456</p>");
        out.println("<p>姓名: 张三</p>");
        out.println("<p>性别: 男</p>");
        out.println("<p>年龄: 23</p>");
        out.println("</body></html>");

        // 刷新并关闭 PrintWriter 对象
        out.flush();
        out.close();
    }
}